﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CorsatAdminApp.Desktop.UserControls;

namespace CorsatAdminApp.Desktop
{
    public partial class Main : Form
    {
        public Main()
        {
            InitializeComponent();
        }


        private void SetPrimaryControl(Type UserControlType)
        {

            UserControl current = null;

            switch (UserControlType.Name)
            {
                case "ucAbscence": current = new ucAbscence(); break;
                case "ucConference": current = new ucConference(); break;
                case "ucResults": current = new ucResults(); break;
                case "ucCourse": current = new ucCourse(); break;
                case "ucItemsAdmin": current = new ucItemsAdmin(); break;
            }

            if (Controls.Count < 3 ||
                Controls[2].Name != UserControlType.Name)
            {
                if (Controls.Count == 3) Controls.RemoveAt(2);
                Controls.Add(current);
            }

            current.Dock = DockStyle.Fill;
        }


        private void abscenceToolStripMenuItem_Click(object sender, EventArgs e)
        {

            SetPrimaryControl(typeof(ucAbscence));
        }



        private void conferenceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SetPrimaryControl(typeof(ucConference));
        }

        private void resultsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SetPrimaryControl(typeof(ucResults));
        }

        private void courseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SetPrimaryControl(typeof(ucCourse));
        }

        private void itemsHandlerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SetPrimaryControl(typeof(ucItemsAdmin));
        }

        private void Main_Load(object sender, EventArgs e)
        {
            
        }
    }
}
